package com.nondo.rdp.finance.model.course;

import java.util.ArrayList;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.nondo.rdp.core.common.BeanUtils;
import com.nondo.rdp.finance.common.DateProcessUtils;
import com.nondo.rdp.finance.domain.course.SectionComment;
import com.nondo.rdp.auth.model.UserBeanInner;

/**
 * 求知-课节评论
 */
public class SectionCommentBean {
	private Long id;// 主键
	private Long sectionId;// 课节ID
	private String body;// 评论内容
	private String authorComment;// 作者回复
	private String commentDate; // 评论日期
	private UserBeanInner user; //评论用户
	private String authorCommentDate;//作者回复时间

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@JsonIgnore
	public Long getSectionId() {
		return sectionId;
	}

	@JsonSetter
	public void setSectionId(Long sectionId) {
		this.sectionId = sectionId;
	}

	public String getBody() {
		return body;
	}

	public void setBody(String body) {
		this.body = body;
	}

	public String getAuthorComment() {
		return authorComment;
	}

	public void setAuthorComment(String authorComment) {
		this.authorComment = authorComment;
	}

	public String getCommentDate() {
		return commentDate;
	}

	public void setCommentDate(String commentDate) {
		this.commentDate = commentDate;
	}

	public UserBeanInner getUser() {
		return user;
	}

	public void setUser(UserBeanInner user) {
		this.user = user;
	}

	public String getAuthorCommentDate() {
		return authorCommentDate;
	}

	public void setAuthorCommentDate(String authorCommentDate) {
		this.authorCommentDate = authorCommentDate;
	}

	public static SectionCommentBean covert2Bean(SectionComment comment) {
		SectionCommentBean commentBean = new SectionCommentBean();
		BeanUtils.copy(comment, commentBean);
		String commentDate = DateProcessUtils.showTimeText(comment.getCreateDate());
		commentBean.setCommentDate(commentDate);
		if (comment.getAuthorCommentDate() != null) {
			String authorCommentDate = DateProcessUtils.showTimeText(comment
					.getAuthorCommentDate());
			commentBean.setAuthorCommentDate(authorCommentDate);
		}
		return commentBean;
	}

	public static List<SectionCommentBean> covert2BeanList(List<SectionComment> comments) {
		List<SectionCommentBean> commentBeanList = new ArrayList<SectionCommentBean>();
		for(SectionComment comment : comments){
			SectionCommentBean commentBean = SectionCommentBean.covert2Bean(comment);
			commentBeanList.add(commentBean);
		}
		return commentBeanList;
	}

}
